<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8">
		<title>Syntax of statements</title>
	</head>
	<body>
		<h1>Syntax of statements and expressions</h1>
			<p>
			Depending on the context, the following types of statements and expressions are valid:
			<ul>
				<li><a href="#statements">Statements</a> (only in process methods)
				<li><a href="#expressions">Expressions</a> (almost everywhere)
			</ul>
			Context-sensitive information is available through the content-assist (&lt;CTRL&gt;+&lt;SPACE&gt;) in the textual editor.
			More information about the POOSL language can be found at <a href="http://www.es.ele.tue.nl/poosl/">http://www.es.ele.tue.nl/poosl/</a>.
			</p>

			<h2><a id="statements"/>Statements (only in process methods)</h2>

<h3>Abort</h3>
<pre>
abort
  skip
with (
  skip;
  skip
)
</pre>
<p>Execute the first statement, but permanently terminate this execution when the other statements execute.</p>

<h3>Delay</h3>
<pre>
delay 1
</pre>
<p>Postpone the execution with a number of time units (integer or real).</p>

<h3>Guard</h3>
<pre>
[true] skip
</pre>
<p>Block the statement whenever the guard does not evaluate to true. The evaluation of the condition and the execution of the statement together form a single execution step.</p>

<h3>If</h3>
<pre>
if true then
  skip
else
  skip
fi
</pre>
<p>Depending on whether the condition evaluates to true, execute the first or the second body statement. The evaluation of the condition and the execution of any of the body statements are two separate execution steps.</p>

<h3>Interrupt</h3>
<pre>
interrupt
  skip
with (
  skip;
  skip
)
</pre>
<p>Execute the first statement, but temporarily suspend this execution when the other statements execute (possibly multiple times).</p>

<h3>Parallel</h3>
<pre>
par
  skip
and
  skip
rap
</pre>
<p>Execute multiple statements in parallel, in an interleaved way. Communication and synchronization within a process can only be performed through shared variables.</p>

<h3>Process method call</h3>
<pre>
method()()
</pre>
<p>Invoke a process method with a series of input parameter values and a series of output variables. If the process method call is the last statement of a method, then there is no danger of stack overflow.</p>

<h3>Select</h3>
<pre>
sel
  skip
or
  skip
les
</pre>
<p>Non-deterministic choice between multiple alternative statements. It is blocked when all alternatives are blocked. The choice is finally resolved by the first statement that executes. Fairness of the choice is not guaranteed.</p>

<h3>Skip</h3>
<pre>
skip
</pre>
<p>Execute without any observeable effect on variables or messages. If used in the context of a sel statement, a skip statement is never blocked, and can resolve the choice. This can be used to model an internal decision.</p>

<h3>Receive</h3>
<pre>
port?msg(var1, var2 | true)
</pre>
<p>Receive a message over a port, and assign the message parameters to variables. The (optional) condition restricts the accepted parameter values.</p>

<h3>Send</h3>
<pre>
port!msg(expr1, expr2)
</pre>
<p>Send a message over a port, and add the expressions as message parameters.</p>

<h3>Switch</h3>
<pre>
switch nil do
  case 42 then
    skip
  default
    skip
od
</pre>
<p>Evaluate the switch expression and all case expressions. Afterwards execute the body statement of a case with an expression that equals the switch expression. If no such case exists, then execute the default body statement.<br/><br/>The evaluation of all expressions and the execution of any of the body statements are separate execution steps.</p>

<h3>While</h3>
<pre>
while true do
  skip
od
</pre>
<p>As long as the condition evaluates to true, execute the statement. The evaluation of the condition and the execution of the statement are two separate execution steps.</p>


		<h2><a id="expressions"/>Expressions (almost everywhere)</h2>

<h3>Assignment</h3>
<pre>
v := nil
</pre>
<p></p>

<h3>Current time</h3>
<pre>
currentTime
</pre>
<p></p>

<h3>Data method call</h3>
<pre>
"foo" printString()
</pre>
<p></p>

<h3>If</h3>
<pre>
if true then
  nil
else
  nil
fi
</pre>
<p>Depending on whether the condition evaluates to true, return the first or the second body expression.</p>

<h3>New</h3>
<pre>
new(Object)
</pre>
<p>Create a new instance of a data class.</p>

<h3>Return</h3>
<pre>
return nil
</pre>
<p></p>

<h3>Self</h3>
<pre>
self
</pre>
<p></p>

<h3>Super</h3>
<pre>
self^
</pre>
<p></p>

<h3>Switch</h3>
<pre>
switch nil do
  case 42 then
    nil
  default
    nil
od
</pre>
<p>Evaluate the switch expression and all case expressions. Afterwards return the body of a case with an expression that equals the switch expression. If no such case exists, then execute the default body.</p>

<h3>While</h3>
<pre>
while true do
  nil
od
</pre>
<p>As long as the condition evaluates to true, evaluate the body expression. Finally return nil.</p>

	</body>
</html>